﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OrgChart.Entity;
using OrgChart.Logic.Interface;
using App.Service;
using OrgChart.Logic;
using App.Utils;

namespace OrgChart
{
    public partial class SecurityManagementRight : System.Web.UI.Page
    {
        DictionaryLogic _logic = new DictionaryLogic();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtUserGroupID.Text = Request.QueryString["UserGroup"];

                LoadDict();
            }
        }

        void LoadDict()
        {
            TreeNode root = new TreeNode();
            root.Text = Resources.lang.Menu;
            TreeView1.Nodes.Add(root);
            List<DictionaryEntity> lists = _logic.GetTopDictionaryList("Menu");
            foreach (DictionaryEntity dict in lists)
            {
                TreeNode tn = new TreeNode(ReflectionUtil.GetPublicPropertyValue(dict,Resources.lang.DICTIONARY_DBNAME).ToString());
                tn.NavigateUrl = "#";
                root.ChildNodes.Add(tn);

                BuildChildNodes(tn, dict.DICTIONARY_ID);
            }

            TreeView1.ExpandAll();
        }

        void BuildChildNodes(TreeNode tn,string dictID)
        {
            List<DictionaryEntity> lists = _logic.GetChildDictionaryList(dictID);
            foreach (DictionaryEntity dict in lists)
            {
                TreeNode t = new TreeNode(ReflectionUtil.GetPublicPropertyValue(dict, Resources.lang.DICTIONARY_DBNAME).ToString());
                t.NavigateUrl = "#";
                tn.ChildNodes.Add(t);
                BuildChildNodes(t, dict.DICTIONARY_ID);
            }
        }

        protected void imgBtnSave_Click(object sender, EventArgs e)
        {
            TreeNodeCollection cols= TreeView1.CheckedNodes;

        }
    }
}